/**********************  企业完善注册  *****************************/
	
	$(document).ready(function() {

	    $('#from_1000001').bootstrapValidator({
	    	message: 'This value is not valid',
            live: 'enabled',
            excluded:[":disabled"],
            trigger: 'live blur',
	        feedbackIcons: {
	        	valid: 'glyphicon glyphicon-ok-sign',
                invalid: 'glyphicon glyphicon-remove-sign',
                validating: 'glyphicon glyphicon-refresh-sign'
	        },
	        fields: {
	        	orgName: {
	        		container: '#orgName_info',
	                validators: {
	                    notEmpty: {
	                        message: '企业名称不能为空'
	                    }
	                }
	            },
	            busiPerson: {
	            	container: '#busiPerson_info',
	                validators: {
	                    notEmpty: {
	                        message: '企业法人姓名不能为空'
	                    }
	                }
	            },
	            idCard: {
	            	container: '#idCard_info',
	                validators: {
	                    notEmpty: {
	                        message: '身份证不能为空'
	                    },
	                    regexp: {
	                        regexp: /^[0-9]+X?$/,
	                        message: '身份证输入有误'
	                    },
	                    callback: { 
	                    	message: '身份证必须为15位或18位', 
	                        callback: function(value, validator) {
	                           if(value.length==15||value.length==18){
	                        	   return true;
	                           }
	                            return false;
	                        }
	                    }
	                }
	            },
	            addr: {
	            	container: '#addr_info',
	                validators: {
	                    notEmpty: {
	                        message: '地址不能为空'
	                    }
	                }
	            },
	            pwd: {
	            	container: '#pwd_info',
	            	validators: {
	            		notEmpty: {
	            			message: '密码不能为空'
	            		},
	            		stringLength: {
	                        min: 6,
	                        max: 30,
	                        message: '密码的长度必须为6-12位'
	                    },
	                    regexp: {
	                        regexp: /^[a-zA-Z0-9_]+$/,
	                        message: '密码只能为数字,字母和下划线'
	                    },
	            	}
	            },
	            recordNo: {
	            	container: '#orgName_info',
	            	validators: {
	            		notEmpty: {
	            			message: '备案号不能为空'
	            		}
	            	}
	            },
	            website: {
	            	container: '#website_info',
	            	validators: {
			            regexp: {
			            	regexp: /^((https|http|ftp|rtsp|mms):\/\/)?[^s]+/,
			            	message: '网址有误 例:http://www.xbdun.com'
			            }
	            	}
	            },
	            orgEmail: {
	            	container: '#orgEmail_info',
	                validators: {
	                	notEmpty: {
	            			message: '企业邮箱不能为空'
	            		},
	                    emailAddress: {
	                        message: '邮箱格式不正确'
	                    }
	                }
	            },
	            orgLandline: {
	            	container: '#orgLandline_info',
	                validators: {
	                	regexp: {
			            	regexp: /[0-9]{3,4}\-[0-9]{6}/,
			            	message: '格式有误,例:023-60661234'
			            }
	                }
	            },
	            orgMobile: {
	            	container: '#orgMobile_info',
	            	validators: {
	            		notEmpty: {
	            			message: '企业电话不能为空'
	            		}
	            	}
	            }
	        }
	    });
	    
	    $('#resetBtn').click(function() {
	        $('#from_1000001').data('bootstrapValidator').resetForm(true);
	    });
	    
	    $("#submit_form").on("click",function(){
	    	if(!$("#txt_logo").val()){
    			$("#reg_result").empty().html("请上传企业Logo");
    			$("#bs-modal-lg").modal("show");
    			return ;
    		}
    		if(!$("#txt_recordImg").val()){
    			$("#reg_result").empty().html("请上传企业备案照");
    			$("#bs-modal-lg").modal("show");
    			return ;
    		}
	    	var bootstrapValidator = $("#from_1000001").data('bootstrapValidator');
	    	bootstrapValidator.validate();
	    	if(bootstrapValidator.isValid()){
	    		
	    		var tempJSon = {data:$("input[name='data']").val()};
				$("#from_1000001 , input[id^='txt_'],select[id^='sel_']").each(function(){
					if ($(this).attr("name")!=undefined&&$(this).attr("disabled")!="disabled"){
						tempJSon[$(this).attr("name")]=$(this).val();
					}
				})
				
		    	$.post(webRoot+"/system/1000001",tempJSon,function(reslt){
					if(reslt){
						if(reslt.success){
							$("#reg_result").empty().html("注册成功,请等待平台管理员审核,通过后我们将通知您");
						}else{
							$("#reg_result").empty().html("注册失败,原因是"+reslt.subMsg);
						}
						$("#bs-modal-lg").modal("show");
					}
				})
	    	}
	    })
	});